import pandas as pd


for i in range(1,8):
    new_df = pd.read_csv(f'{i}.csv')
    old_df = pd.read_csv(f'./merged_output/{i}.csv')
    # 提取predicted_rainfall和Date
    new_df1 = new_df[['date', 'predicted_rainfall']]
    new_df2 = new_df[['date', 'rainfall_probability']]
    old_df1 = old_df[['date', '降雨']][-5:]  # 取最后5行
    old_df1.rename(columns={'降雨': 'rainfall'}, inplace=True)
    new_df1.rename(columns={'predicted_rainfall': 'rainfall'}, inplace=True)
    new_df = pd.concat([old_df1,new_df1], axis=0)
    new_df.to_csv(f'./rain/{i}.csv', index=False)
    new_df2.to_csv(f'./rainfall_probability/{i}.csv', index=False)
